#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string a, b;

long long dp[4096][4096] = {};

int main(int argc, char const *argv[])
{
    cin >> a >> b;
    for (int i = 0; i < a.size(); i++)
    {
        for (int j = 0; j < b.size(); j++)
        {
            if (a[i] == b[j])
            {
                if (i == 0) 
                    dp[i][j] = j;
                else if (j == 0)
                    dp[i][j] = i;
                else
                    dp[i][j] = dp[i - 1][j - 1];
            }
            else
            {
                if (i == 0 && j == 0)
                    dp[i][j] = 1;
                else if (i == 0)
                    dp[i][j] = min((long long)j + 1, 1 + dp[i][j - 1]);
                else if (j == 0)
                    dp[i][j] = min((long long)i + 1, 1 + dp[i - 1][j]);
                else
                    dp[i][j] = min(1 + dp[i - 1][j - 1], min(1 + dp[i - 1][j], 1 + dp[i][j - 1]));
            }
        }
    }
    // for (int i = 0; i < a.size(); i++)
    // {
    //     for (int j = 0; j < b.size(); j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[a.size() - 1][b.size() - 1];
    return 0;
}
